package com.zym.init.model.query;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zym.init.core.annotation.EnumRange;
import com.zym.init.enums.UserStatusEnum;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.groups.Default;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;
import java.util.Set;

/**
 * 用户查询对象
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class UserQuery extends PageQuery {
    /**
     * 用户ID
     */
    @NotNull(message = "用户ID不能为空", groups = {Update.class})
    private Long userId;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 用户名
     */
    @NotEmpty(message = "用户名不能为空", groups = {Add.class})
    private String username;

    /**
     * 密码
     */
    @NotEmpty(message = "密码不能为空", groups = {Add.class})
    private String password;

    /**
     * 角色
     */
    private Set<String> roleList;

    /**
     * 状态
     */
    @EnumRange(message = "用户状态错误", enumClass = UserStatusEnum.class, enumValidMethod = "isValidCode", groups = {Update.class})
    private String status;

    /**
     * 封禁时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date suspendedTime;


    /**
     * 新增用户校验组
     */
    public interface Add extends Default {
    }

    /**
     * 更新用户校验组
     */
    public interface Update extends Default {
    }

}
